package api

import (
	"github.com/teambition/gear"
	"net/http"
	"lutai/src/model"
	"lutai/src/bll"
	"lutai/src/logger"
)

// Company API接口
type Company struct {
	models  *model.All
	companyBll *bll.Company
}

// Init 初始化服务配置
func (c *Company) Init(blls *bll.All) *Company {
	c.models = blls.Models
	c.companyBll = blls.Company
	return c
}

// Query /test
func (c *Company) Query(ctx *gear.Context) (err error) {
	companys, err := c.companyBll.Query()
	if err != nil {
		logger.Errorf("Query Error:%s", err.Error())
		return gear.ErrInternalServerError
	}

	return ctx.JSON(http.StatusOK, companys)
}
